//###############
// FILE : AfterFilter.java
// WRITER : Yaron Dinur, yarondi, 200184992
// WRITER : Yuval Ran, yuvran21, 032513483
// EXERCISE : oop ex1 2011
// DESCRIPTION:
//Abstract class - for filters which are using dates
//###############

package filters;

import java.util.Date;
import java.text.SimpleDateFormat;


public abstract class DateFilter implements FileFilter {
	
	/** Date format as required */
	public static final String DATE_FORMAT = "yyyyMMdd";
	
	/** A string which represents the date*/
	String _date;
	
	/**
	 * Constructor
	 * @param date the date which is used for the filter.
	 */
	public DateFilter (String date){
		_date = date;		
	}
	
	/**
	 * Converts the milliseconds which are retrieved from the file into
	 * a Date object and from this object it produces the date in the required
	 * format 
	 * @param lastModified the milliseconds which passed since the file was
	 * last modified
	 * @return the date in the required format
	 */
	protected String convertDateToString(long lastModified){
		Date date = new Date(lastModified);
		SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT);
		return format.format(date);		
	}

}
